package springapp.dao;

import java.util.List;

import org.hibernate.criterion.Criterion;
import org.springframework.stereotype.Repository;

import springapp.entity.CompanyEntity;
import springapp.util.CompanyEntitySetterFactory;
import springapp.util.IEntitySetter;
import springapp.util.ObjectTypeCaster;
import springapp.util.TypeCasterFactory;

@Repository
public class CompanyDao extends HibernateDao<CompanyEntity, Integer> {

	public static String[] COMPANY_COLUMNS = new String[] { "companyId",
			"companyName", "headquarters", "industryId", "rating" };

	@SuppressWarnings("rawtypes")
	public static final ObjectTypeCaster[] typeCasters = new ObjectTypeCaster[] {
			TypeCasterFactory.INTEGER_CASTER, TypeCasterFactory.STRING_CASTER,
			TypeCasterFactory.INTEGER_CASTER, TypeCasterFactory.INTEGER_CASTER,
			TypeCasterFactory.FLOAT_CASTER };

	@SuppressWarnings("rawtypes")
	public static final IEntitySetter[] entitySetters = new IEntitySetter[] {
			CompanyEntitySetterFactory.idSetter,
			CompanyEntitySetterFactory.companyNameSetter,
			CompanyEntitySetterFactory.hqSetter,
			CompanyEntitySetterFactory.industryIdSetter,
			CompanyEntitySetterFactory.ratingSetter };

	public static final EntityGenerator<CompanyEntity> companyEntityGenerator = new EntityGenerator<CompanyEntity>() {

		public CompanyEntity getEntity() {
			return new CompanyEntity();
		}
	};

	/**
	 * is this constructor really required
	 */
	public CompanyDao() {
		super();
	}

	@Deprecated
	public List<CompanyEntity> getColumns(Criterion[] criterion) {
		return super.getColumns(COMPANY_COLUMNS, criterion, entitySetters,
				typeCasters, companyEntityGenerator);
	}

}
